<?php
	$showPage = false; 

	//var_dump($authority->getAuthority("group_manager",$_SESSION['id']));
	if($authority->getAuthority("create_group",$_SESSION['id']) == true)
	{
		$showPage = true;
		
		if($_POST)
		{
			$createGroupInsertSQLText = "
				INSERT INTO snm_group 
				(group_name, note) 
				VALUES
				(
					'".$db->escape($_POST['group_name'])."',
					'".$db->escape($_POST['note'])."'
				) 
			";
			if($db->sql($createGroupInsertSQLText))
			{
				$groupID = $db->sonid();
				foreach($_POST['auth'] as $modul=>$value)
				{
					$db->sql(" INSERT INTO snm_authority (group_id , module) VALUES (".$groupID.", '".$modul."' ) ");
				}	
				$hata['sonuc'] = true;
				$hata['aciklama'] = ' Create a Group completed.';
			}
			else
			{
				$hata['sonuc'] = false;
				$hata['aciklama'] = ' SQL Error!';
			}
			
		}
		
	}
	
	include "template/create_group.php";
?>
